home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / c_examples / button / button_example.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-15  |  1.4 KB  |  62 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. // Button Example
  3. // 5.18.96 Deryk Robosson
  4.  
  5. //////////////////////////////////////////////////////////////////////////////
  6. // Includes
  7. #include "aframe:include/amigaapp.hpp"
  8. #include "aframe:include/window.hpp"
  9. #include "aframe:include/rect.hpp"
  10. #include "aframe:include/button.hpp"
  11. #include "aframe:include/reqtools.hpp"
  12.  
  13. //////////////////////////////////////////////////////////////////////////////
  14. // ControlWindow Class Definition
  15.  
  16. class ControlWindow : public AFWindow
  17.  
  18. {
  19. public:
  20.     virtual void OnGadgetUp(LPIntuiMessage imess);
  21.  
  22.     AFButton button;
  23.     AFReqTools rt;
  24. };
  25.  
  26. //////////////////////////////////////////////////////////////////////////////
  27. // ControlWindow Implementation routines
  28.  
  29. void ControlWindow::OnGadgetUp(LPIntuiMessage imess)
  30. {
  31.   switch(((struct Gadget*)imess->IAddress)->GadgetID) {
  32.  
  33.   case 100:     // Test button
  34.     rt.EZRequest("Test button selected","Ok");
  35.     rt.FileRequest();
  36.     printf("File Selected: %s\n",rt.filename);
  37.     break;
  38.   default:
  39.     AFWindow::OnGadgetUp(imess);
  40.     break;
  41.   }
  42. }
  43.  
  44. //////////////////////////////////////////////////////////////////////////////
  45. // MAIN
  46.  
  47. void main()
  48. {
  49.     AFAmigaApp theApp;
  50.     ControlWindow win;
  51.     AFRect rect(10,10,410,310);
  52.  
  53.     win.Create(&theApp,&rect,"AFrame Button Example");
  54.  
  55.     rect.SetRect(10,10,50,50);
  56.     win.button.Create("Button",&win,&rect,100);
  57.  
  58.     win.RefreshGadgets();
  59.  
  60.     theApp.RunApp();
  61. }
  62.